#include "taskQueue.h"
//初始化
int taskQueueInit(taskQueue_t *que){
    bzero(que,sizeof(taskQueue_t));
    return 0;
}
//入队
int enQueue(taskQueue_t *que,int netfd){
    if(que==NULL){
        printf("error enQueue!\n");
        return -1;
    }
    node_t *pnew=(node_t *)calloc(1,sizeof(node_t));
    pnew->data=netfd;
    if(que->queSize==0){
       que->head=pnew;
       que->tail=pnew;
    }else{
        que->tail->pnext=pnew;
        que->tail=pnew;
    }
    que->queSize++;
    return 0;
}
//出队
int deQueue(taskQueue_t *que){
    node_t *pcur=que->head;
    que->head=pcur->pnext;
    if(que->queSize==1){
        que->tail=NULL;
    }
    free(pcur);
    que->queSize--;
    return 0;
}
//打印队列
int printQueue(taskQueue_t *que){
    node_t *pcur=que->head;
    while(pcur){
        printf("%3d",pcur->data);
        pcur=pcur->pnext;
    }
    printf("\n");
    return 0;
}
